package com.wulaobo.transformer;

import com.wulaobo.pojo.WaterSensor;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * @Author wuwenbo
 * @Date 2024/5/17 10:31
 * @ClassName: MapDemo
 * @Description: TODO
 */
public class FilterDemo {

    public static void main(String[] args) throws Exception {

        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        env.setParallelism(1);

        DataStreamSource<WaterSensor> stream = env.fromElements(
                new WaterSensor("sensor_1", 1, 1),
                new WaterSensor("sensor_2", 2, 2),
                new WaterSensor("sensor_2", 2, 3),
                new WaterSensor("sensor_4", 3, 4),
                new WaterSensor("sensor_5", 4, 5)
        );

        stream.filter(e -> "sensor_2".equals(e.getId())).print();


        env.execute();
    }

}
